
package dialogs;

import core.COINCOMOSubComponent;
import core.COINCOMOSubSystem;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.xml.ws.Response;
import main.GlobalMethods;
import main.Icons;
import panels.ComponentOverviewPanel;
import database.COINCOMOSubSystemManager;


/**
 *
 * @author Raed Shomali
 */
public class SubSystemSizeDialog extends JDialog implements ActionListener, ChangeListener
{


    char popupflag='n';
    // Function Points

    JCheckBox checkBox = new JCheckBox("Reuse");

    JLabel easyLabel1 = new JLabel("Easy");
    JLabel nominalLabel1 = new JLabel("Nominal");
    JLabel difficultLabel1 = new JLabel("Difficult");
    JLabel sysReqLabelNoReuse = new JLabel("# of System Requirements" );
    JLabel sysReqLabel = new JLabel( "# of New System Requirements" );
    JLabel reuseSysReqLabel = new JLabel( "# of Design For Reuse System Requirements" );
    JLabel modifiedReqLabel = new JLabel( "# of Modified System Requirements" );
    JLabel deletedReqLabel = new JLabel( "# of Deleted System Requirements" );
    JLabel adoptedReqLabel = new JLabel( "# of Adopted System Requirements" );
    JLabel managedReqLabel = new JLabel( "# of Managed System Requirements" );
    JTextField functionTextField1[] = new JTextField[ 21 ];



    JLabel easyLabel2 = new JLabel( "Easy" );
    JLabel nominalLabel2 = new JLabel( "Nominal" );
    JLabel difficultLabel2 = new JLabel( "Difficult" );
    JLabel sysInfLabelNoReuse = new JLabel("# of System Interfaces" );
    JLabel sysInfLabel = new JLabel( "# of New System Interfaces" );
    JLabel reuseSysInfLabel = new JLabel( "# of Design For Reuse System Interfaces" );
    JLabel modifiedInfLabel = new JLabel( "# of Modified System Interfaces" );
    JLabel deletedInfLabel = new JLabel( "# of Deleted System Interfaces" );
    JLabel adoptedInfLabel = new JLabel( "# of Adopted System Interfaces" );
    JLabel managedInfLabel = new JLabel( "# of Managed System Interfaces" );
    JTextField functionTextField2[] = new JTextField[ 21 ];


    JLabel easyLabel3 = new JLabel( "Easy" );
    JLabel nominalLabel3 = new JLabel( "Nominal" );
    JLabel difficultLabel3 = new JLabel( "Difficult" );
    JLabel sysAlgLabelNoReuse = new JLabel("# of Algorithms" );
    JLabel sysAlgLabel = new JLabel( "# of New Algorithms" );
    JLabel reuseSysAlgLabel = new JLabel( "# of Design For Reuse Algorithms" );
    JLabel modifiedAlgLabel = new JLabel( "# of Modified Algorithms" );
    JLabel deletedAlgLabel = new JLabel( "# of Deleted System Algorithms" );
    JLabel adoptedAlgLabel = new JLabel( "# of Adopted System Algorithms" );
    JLabel managedAlgLabel = new JLabel( "# of Managed Algorithms" );
    JTextField functionTextField3[] = new JTextField[ 21 ];

    JLabel easyLabel4 = new JLabel( "Easy" );
    JLabel nominalLabel4 = new JLabel( "Nominal" );
    JLabel difficultLabel4 = new JLabel( "Difficult" );
    JLabel sysOsceLabelNoReuse = new JLabel("# of Operational Scenarios" );
    JLabel sysOsceLabel = new JLabel( "# of New Operational Scenarios" );
    JLabel reuseSysOsceLabel = new JLabel( "# of Design For Reuse Operational Scenarios" );
    JLabel modifiedOsceLabel = new JLabel( "# of Modified Operational Scenarios" );
    JLabel deletedOsceLabel = new JLabel( "# of Deleted Operational Scenarios" );
    JLabel adoptedOsceLabel = new JLabel( "# of Adopted Operational Scenarios" );
    JLabel managedOsceLabel = new JLabel( "# of Managed Operational Scenarios" );
    JTextField functionTextField4[] = new JTextField[ 21 ];

    // Tabs and Buttons
    JTabbedPane tabs = new JTabbedPane();
    JButton applyButton = new JButton( "Apply" );
    JButton closeButton = new JButton( "Close" );
    COINCOMOSubSystem subSystem = null;

    int rowNumber = 0;

    public SubSystemSizeDialog( JFrame owner , COINCOMOSubSystem subSystem , int rowNumber )
    {
        super( owner );

        this.setModal( true );
        this.setTitle( "Size - " + subSystem.getName() );
        this.rowNumber = rowNumber;
        this.subSystem = subSystem;
        GlobalMethods.updateStatusBar( "Done." );
  
        // checkbox

        checkBox.addActionListener(this);

        // Buttons
        applyButton.addActionListener( this );
        closeButton.addActionListener( this );

        applyButton.setFocusable( false );
        closeButton.setFocusable( false );

        applyButton.setIcon( Icons.SAVE_ICON );
        closeButton.setIcon( Icons.CLOSE_ICON );

        // Panel Tabs
      
        easyLabel1.setFont( new Font( "arial" , 1 , 11 ) );
        nominalLabel1.setFont( new Font( "arial" , 1 , 11 ) );
        difficultLabel1.setFont( new Font( "arial" , 1 , 11 ) );
        sysReqLabelNoReuse.setFont( new Font( "arial" , 1 , 11 ) );
        sysReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        reuseSysReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        modifiedReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        deletedReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        adoptedReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        managedReqLabel.setFont( new Font( "arial" , 1 , 11 ) );
        
        easyLabel1.setHorizontalAlignment( JLabel.CENTER );
        nominalLabel1.setHorizontalAlignment( JLabel.CENTER );
        difficultLabel1.setHorizontalAlignment( JLabel.CENTER );
        sysReqLabelNoReuse.setHorizontalAlignment( JLabel.CENTER );
        sysReqLabel.setHorizontalAlignment( JLabel.CENTER );
        reuseSysReqLabel.setHorizontalAlignment( JLabel.CENTER );
        modifiedReqLabel.setHorizontalAlignment( JLabel.CENTER );
        deletedReqLabel.setHorizontalAlignment( JLabel.CENTER );
        adoptedReqLabel.setHorizontalAlignment( JLabel.CENTER );
        managedReqLabel.setHorizontalAlignment( JLabel.CENTER );

        easyLabel1.setBounds(270, 20, 50, 20);
        nominalLabel1.setBounds(330, 20, 50, 20);
        difficultLabel1.setBounds(390, 20, 50, 20);
        sysReqLabelNoReuse.setBounds( 0 , 40 , 280 , 20 );
        sysReqLabel.setBounds( 0 , 60 , 280 , 20 );
        reuseSysReqLabel.setBounds( 0 , 80 , 280 , 20 );
        modifiedReqLabel.setBounds( 0 , 100 , 280 , 20 );
        deletedReqLabel.setBounds( 0 , 120 , 280 , 20 );
        adoptedReqLabel.setBounds( 0 , 140 , 280 , 20 );
        managedReqLabel.setBounds( 0 , 160 , 280 , 20 );

        
        JPanel functionPointsPanel1 = new JPanel( null );
        functionPointsPanel1.add( easyLabel1 );
        functionPointsPanel1.add( nominalLabel1 );
        functionPointsPanel1.add( difficultLabel1 );
        functionPointsPanel1.add( sysReqLabelNoReuse );
        functionPointsPanel1.add( sysReqLabel );
        functionPointsPanel1.add( reuseSysReqLabel );
        functionPointsPanel1.add( modifiedReqLabel );
        functionPointsPanel1.add( deletedReqLabel );
        functionPointsPanel1.add( adoptedReqLabel );
        functionPointsPanel1.add( managedReqLabel );
        

        functionTextField1[ 0] = new JTextField();
        functionTextField1[ 1] = new JTextField();
        functionTextField1[ 2] = new JTextField();
        functionTextField1[ 3] = new JTextField();
        functionTextField1[ 4] = new JTextField();
        functionTextField1[ 5] = new JTextField();
        functionTextField1[ 6] = new JTextField();
        functionTextField1[ 7] = new JTextField();
        functionTextField1[ 8] = new JTextField();
        functionTextField1[ 9] = new JTextField();
        functionTextField1[ 10] = new JTextField();
        functionTextField1[ 11] = new JTextField();
        functionTextField1[ 12] = new JTextField();
        functionTextField1[ 13] = new JTextField();
        functionTextField1[ 14] = new JTextField();
        functionTextField1[ 15] = new JTextField();
        functionTextField1[ 16] = new JTextField();
        functionTextField1[ 17] = new JTextField();
        functionTextField1[ 18] = new JTextField();
        functionTextField1[ 19] = new JTextField();
        functionTextField1[ 20] = new JTextField();

        functionTextField1[ 0].setBounds( 285 , 40 , 50 , 20 );
        functionTextField1[ 1].setBounds( 335 , 40 , 50 , 20 );
        functionTextField1[ 2].setBounds( 385 , 40 , 50 , 20 );
        functionTextField1[ 3].setBounds( 285 , 60 , 50 , 20 );
        functionTextField1[ 4].setBounds( 335 , 60 , 50 , 20 );
        functionTextField1[ 5].setBounds( 385 , 60 , 50 , 20 );
        functionTextField1[ 6].setBounds( 285 , 80 , 50 , 20 );
        functionTextField1[ 7].setBounds( 335 , 80 , 50 , 20 );
        functionTextField1[ 8].setBounds( 385 , 80 , 50 , 20 );
        functionTextField1[ 9].setBounds( 285 , 100 , 50 , 20 );
        functionTextField1[ 10].setBounds( 335 , 100 , 50 , 20 );
        functionTextField1[ 11].setBounds( 385 , 100 , 50 , 20 );
        functionTextField1[ 12].setBounds( 285 , 120 , 50 , 20 );
        functionTextField1[ 13].setBounds( 335 , 120 , 50 , 20 );
        functionTextField1[ 14].setBounds( 385 , 120 , 50 , 20 );
        functionTextField1[ 15].setBounds( 285 , 140 , 50 , 20 );
        functionTextField1[ 16].setBounds( 335 , 140 , 50 , 20 );
        functionTextField1[ 17].setBounds( 385 , 140 , 50 , 20 );
        functionTextField1[ 18].setBounds( 285 , 160 , 50 , 20 );
        functionTextField1[ 19].setBounds( 335 , 160 , 50 , 20 );
        functionTextField1[ 20].setBounds( 385 , 160 , 50 , 20 );


        functionPointsPanel1.add( functionTextField1[ 0] );
        functionPointsPanel1.add( functionTextField1[ 1] );
        functionPointsPanel1.add( functionTextField1[ 2] );
        functionPointsPanel1.add( functionTextField1[ 3] );
        functionPointsPanel1.add( functionTextField1[ 4] );
        functionPointsPanel1.add( functionTextField1[ 5] );
        functionPointsPanel1.add( functionTextField1[ 6] );
        functionPointsPanel1.add( functionTextField1[ 7] );
        functionPointsPanel1.add( functionTextField1[ 8] );
        functionPointsPanel1.add( functionTextField1[ 9] );
        functionPointsPanel1.add( functionTextField1[ 10] );
        functionPointsPanel1.add( functionTextField1[ 11] );
        functionPointsPanel1.add( functionTextField1[ 12] );
        functionPointsPanel1.add( functionTextField1[ 13] );
        functionPointsPanel1.add( functionTextField1[ 14] );
        functionPointsPanel1.add( functionTextField1[ 15] );
        functionPointsPanel1.add( functionTextField1[ 16] );
        functionPointsPanel1.add( functionTextField1[ 17] );
        functionPointsPanel1.add( functionTextField1[ 18] );
        functionPointsPanel1.add( functionTextField1[ 19] );
        functionPointsPanel1.add( functionTextField1[ 20] );

        for(int i=3;i<=20;i++){
        functionTextField1[i].disable();
        }
             
        easyLabel2.setFont( new Font( "arial" , 1 , 11 ) );
        nominalLabel2.setFont( new Font( "arial" , 1 , 11 ) );
        difficultLabel2.setFont( new Font( "arial" , 1 , 11 ) );
        sysInfLabelNoReuse.setFont( new Font( "arial" , 1 , 11 ) );
        sysInfLabel.setFont( new Font( "arial" , 1 , 11 ) );
        reuseSysInfLabel.setFont( new Font( "arial" , 1 , 11 ) );
        modifiedInfLabel.setFont( new Font( "arial" , 1 , 11 ) );
        deletedInfLabel.setFont( new Font( "arial" , 1 , 11 ) );
        adoptedInfLabel.setFont( new Font( "arial" , 1 , 11 ) );
        managedInfLabel.setFont( new Font( "arial" , 1 , 11 ) );

        easyLabel2.setHorizontalAlignment( JLabel.CENTER );
        nominalLabel2.setHorizontalAlignment( JLabel.CENTER );
        difficultLabel2.setHorizontalAlignment( JLabel.CENTER );
        sysInfLabelNoReuse.setHorizontalAlignment( JLabel.CENTER );
        sysInfLabel.setHorizontalAlignment( JLabel.CENTER );
        reuseSysInfLabel.setHorizontalAlignment( JLabel.CENTER );
        modifiedInfLabel.setHorizontalAlignment( JLabel.CENTER );
        deletedInfLabel.setHorizontalAlignment( JLabel.CENTER );
        adoptedInfLabel.setHorizontalAlignment( JLabel.CENTER );
        managedInfLabel.setHorizontalAlignment( JLabel.CENTER );

        easyLabel2.setBounds(270, 20, 50, 20);
        nominalLabel2.setBounds(330, 20, 50, 20);
        difficultLabel2.setBounds(390, 20, 50, 20);
        sysInfLabelNoReuse.setBounds( 0 , 40 , 280 , 20 );
        sysInfLabel.setBounds( 0 , 60 , 280 , 20 );
        reuseSysInfLabel.setBounds( 0 , 80 , 280 , 20 );
        modifiedInfLabel.setBounds( 0 , 100 , 280 , 20 );
        deletedInfLabel.setBounds( 0 , 120 , 280 , 20 );
        adoptedInfLabel.setBounds( 0 , 140 , 280 , 20 );
        managedInfLabel.setBounds( 0 , 160 , 280 , 20 );


        JPanel functionPointsPanel2 = new JPanel( null );
        functionPointsPanel2.add( easyLabel2 );
        functionPointsPanel2.add( nominalLabel2 );
        functionPointsPanel2.add( difficultLabel2 );
        functionPointsPanel2.add( sysInfLabelNoReuse );
        functionPointsPanel2.add( sysInfLabel );
        functionPointsPanel2.add( reuseSysInfLabel );
        functionPointsPanel2.add( modifiedInfLabel );
        functionPointsPanel2.add( deletedInfLabel );
        functionPointsPanel2.add( adoptedInfLabel );
        functionPointsPanel2.add( managedInfLabel );


        functionTextField2[ 0] = new JTextField();
        functionTextField2[ 1] = new JTextField();
        functionTextField2[ 2] = new JTextField();
        functionTextField2[ 3] = new JTextField();
        functionTextField2[ 4] = new JTextField();
        functionTextField2[ 5] = new JTextField();
        functionTextField2[ 6] = new JTextField();
        functionTextField2[ 7] = new JTextField();
        functionTextField2[ 8] = new JTextField();
        functionTextField2[ 9] = new JTextField();
        functionTextField2[ 10] = new JTextField();
        functionTextField2[ 11] = new JTextField();
        functionTextField2[ 12] = new JTextField();
        functionTextField2[ 13] = new JTextField();
        functionTextField2[ 14] = new JTextField();
        functionTextField2[ 15] = new JTextField();
        functionTextField2[ 16] = new JTextField();
        functionTextField2[ 17] = new JTextField();
        functionTextField2[ 18] = new JTextField();
        functionTextField2[ 19] = new JTextField();
        functionTextField2[ 20] = new JTextField();

        functionTextField2[ 0].setBounds( 285 , 40 , 50 , 20 );
        functionTextField2[ 1].setBounds( 335 , 40 , 50 , 20 );
        functionTextField2[ 2].setBounds( 385 , 40 , 50 , 20 );
        functionTextField2[ 3].setBounds( 285 , 60 , 50 , 20 );
        functionTextField2[ 4].setBounds( 335 , 60 , 50 , 20 );
        functionTextField2[ 5].setBounds( 385 , 60 , 50 , 20 );
        functionTextField2[ 6].setBounds( 285 , 80 , 50 , 20 );
        functionTextField2[ 7].setBounds( 335 , 80 , 50 , 20 );
        functionTextField2[ 8].setBounds( 385 , 80 , 50 , 20 );
        functionTextField2[ 9].setBounds( 285 , 100 , 50 , 20 );
        functionTextField2[ 10].setBounds( 335 , 100 , 50 , 20 );
        functionTextField2[ 11].setBounds( 385 , 100 , 50 , 20 );
        functionTextField2[ 12].setBounds( 285 , 120 , 50 , 20 );
        functionTextField2[ 13].setBounds( 335 , 120 , 50 , 20 );
        functionTextField2[ 14].setBounds( 385 , 120 , 50 , 20 );
        functionTextField2[ 15].setBounds( 285 , 140 , 50 , 20 );
        functionTextField2[ 16].setBounds( 335 , 140 , 50 , 20 );
        functionTextField2[ 17].setBounds( 385 , 140 , 50 , 20 );
        functionTextField2[ 18].setBounds( 285 , 160 , 50 , 20 );
        functionTextField2[ 19].setBounds( 335 , 160 , 50 , 20 );
        functionTextField2[ 20].setBounds( 385 , 160 , 50 , 20 );

        functionPointsPanel2.add( functionTextField2[ 0] );
        functionPointsPanel2.add( functionTextField2[ 1] );
        functionPointsPanel2.add( functionTextField2[ 2] );
        functionPointsPanel2.add( functionTextField2[ 3] );
        functionPointsPanel2.add( functionTextField2[ 4] );
        functionPointsPanel2.add( functionTextField2[ 5] );
        functionPointsPanel2.add( functionTextField2[ 6] );
        functionPointsPanel2.add( functionTextField2[ 7] );
        functionPointsPanel2.add( functionTextField2[ 8] );
        functionPointsPanel2.add( functionTextField2[ 9] );
        functionPointsPanel2.add( functionTextField2[ 10] );
        functionPointsPanel2.add( functionTextField2[ 11] );
        functionPointsPanel2.add( functionTextField2[ 12] );
        functionPointsPanel2.add( functionTextField2[ 13] );
        functionPointsPanel2.add( functionTextField2[ 14] );
        functionPointsPanel2.add( functionTextField2[ 15] );
        functionPointsPanel2.add( functionTextField2[ 16] );
        functionPointsPanel2.add( functionTextField2[ 17] );
        functionPointsPanel2.add( functionTextField2[ 18] );
        functionPointsPanel2.add( functionTextField2[ 19] );
        functionPointsPanel2.add( functionTextField2[ 20] );

        for(int i=3;i<=20;i++){
        functionTextField2[i].disable();
        }

        easyLabel3.setFont( new Font( "arial" , 1 , 11 ) );
        nominalLabel3.setFont( new Font( "arial" , 1 , 11 ) );
        difficultLabel3.setFont( new Font( "arial" , 1 , 11 ) );
        sysAlgLabelNoReuse.setFont( new Font( "arial" , 1 , 11 ) );
        sysAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );
        reuseSysAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );
        modifiedAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );
        deletedAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );
        adoptedAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );
        managedAlgLabel.setFont( new Font( "arial" , 1 , 11 ) );

        easyLabel3.setHorizontalAlignment( JLabel.CENTER );
        nominalLabel3.setHorizontalAlignment( JLabel.CENTER );
        difficultLabel3.setHorizontalAlignment( JLabel.CENTER );
        sysAlgLabelNoReuse.setHorizontalAlignment( JLabel.CENTER );
        sysAlgLabel.setHorizontalAlignment( JLabel.CENTER );
        reuseSysAlgLabel.setHorizontalAlignment( JLabel.CENTER );
        modifiedAlgLabel.setHorizontalAlignment( JLabel.CENTER );
        deletedAlgLabel.setHorizontalAlignment( JLabel.CENTER );
        adoptedAlgLabel.setHorizontalAlignment( JLabel.CENTER );
        managedAlgLabel.setHorizontalAlignment( JLabel.CENTER );

        easyLabel3.setBounds(270, 20, 50, 20);
        nominalLabel3.setBounds(330, 20, 50, 20);
        difficultLabel3.setBounds(390, 20, 50, 20);
        sysAlgLabelNoReuse.setBounds( 0 , 40 , 280 , 20 );
        sysAlgLabel.setBounds( 0 , 60 , 280 , 20 );
        reuseSysAlgLabel.setBounds( 0 , 80 , 280 , 20 );
        modifiedAlgLabel.setBounds( 0 , 100 , 280 , 20 );
        deletedAlgLabel.setBounds( 0 , 120 , 280 , 20 );
        adoptedAlgLabel.setBounds( 0 , 140 , 280 , 20 );
        managedAlgLabel.setBounds( 0 , 160 , 280 , 20 );

        JPanel functionPointsPanel3 = new JPanel( null );
        functionPointsPanel3.add( easyLabel3 );
        functionPointsPanel3.add( nominalLabel3 );
        functionPointsPanel3.add( difficultLabel3 );
        functionPointsPanel3.add( sysAlgLabelNoReuse );
        functionPointsPanel3.add( sysAlgLabel );
        functionPointsPanel3.add( reuseSysAlgLabel );
        functionPointsPanel3.add( modifiedAlgLabel );
        functionPointsPanel3.add( deletedAlgLabel );
        functionPointsPanel3.add( adoptedAlgLabel );
        functionPointsPanel3.add( managedAlgLabel );


        functionTextField3[ 0] = new JTextField();
        functionTextField3[ 1] = new JTextField();
        functionTextField3[ 2] = new JTextField();
        functionTextField3[ 3] = new JTextField();
        functionTextField3[ 4] = new JTextField();
        functionTextField3[ 5] = new JTextField();
        functionTextField3[ 6] = new JTextField();
        functionTextField3[ 7] = new JTextField();
        functionTextField3[ 8] = new JTextField();
        functionTextField3[ 9] = new JTextField();
        functionTextField3[ 10] = new JTextField();
        functionTextField3[ 11] = new JTextField();
        functionTextField3[ 12] = new JTextField();
        functionTextField3[ 13] = new JTextField();
        functionTextField3[ 14] = new JTextField();
        functionTextField3[ 15] = new JTextField();
        functionTextField3[ 16] = new JTextField();
        functionTextField3[ 17] = new JTextField();
        functionTextField3[ 18] = new JTextField();
        functionTextField3[ 19] = new JTextField();
        functionTextField3[ 20] = new JTextField();

        functionTextField3[ 0].setBounds( 285 , 40 , 50 , 20 );
        functionTextField3[ 1].setBounds( 335 , 40 , 50 , 20 );
        functionTextField3[ 2].setBounds( 385 , 40 , 50 , 20 );
        functionTextField3[ 3].setBounds( 285 , 60 , 50 , 20 );
        functionTextField3[ 4].setBounds( 335 , 60 , 50 , 20 );
        functionTextField3[ 5].setBounds( 385 , 60 , 50 , 20 );
        functionTextField3[ 6].setBounds( 285 , 80 , 50 , 20 );
        functionTextField3[ 7].setBounds( 335 , 80 , 50 , 20 );
        functionTextField3[ 8].setBounds( 385 , 80 , 50 , 20 );
        functionTextField3[ 9].setBounds( 285 , 100 , 50 , 20 );
        functionTextField3[ 10].setBounds( 335 , 100 , 50 , 20 );
        functionTextField3[ 11].setBounds( 385 , 100 , 50 , 20 );
        functionTextField3[ 12].setBounds( 285 , 120 , 50 , 20 );
        functionTextField3[ 13].setBounds( 335 , 120 , 50 , 20 );
        functionTextField3[ 14].setBounds( 385 , 120 , 50 , 20 );
        functionTextField3[ 15].setBounds( 285 , 140 , 50 , 20 );
        functionTextField3[ 16].setBounds( 335 , 140 , 50 , 20 );
        functionTextField3[ 17].setBounds( 385 , 140 , 50 , 20 );
        functionTextField3[ 18].setBounds( 285 , 160 , 50 , 20 );
        functionTextField3[ 19].setBounds( 335 , 160 , 50 , 20 );
        functionTextField3[ 20].setBounds( 385 , 160 , 50 , 20 );

        functionPointsPanel3.add( functionTextField3[ 0] );
        functionPointsPanel3.add( functionTextField3[ 1] );
        functionPointsPanel3.add( functionTextField3[ 2] );
        functionPointsPanel3.add( functionTextField3[ 3] );
        functionPointsPanel3.add( functionTextField3[ 4] );
        functionPointsPanel3.add( functionTextField3[ 5] );
        functionPointsPanel3.add( functionTextField3[ 6] );
        functionPointsPanel3.add( functionTextField3[ 7] );
        functionPointsPanel3.add( functionTextField3[ 8] );
        functionPointsPanel3.add( functionTextField3[ 9] );
        functionPointsPanel3.add( functionTextField3[ 10] );
        functionPointsPanel3.add( functionTextField3[ 11] );
        functionPointsPanel3.add( functionTextField3[ 12] );
        functionPointsPanel3.add( functionTextField3[ 13] );
        functionPointsPanel3.add( functionTextField3[ 14] );
        functionPointsPanel3.add( functionTextField3[ 15] );
        functionPointsPanel3.add( functionTextField3[ 16] );
        functionPointsPanel3.add( functionTextField3[ 17] );
        functionPointsPanel3.add( functionTextField3[ 18] );
        functionPointsPanel3.add( functionTextField3[ 19] );
        functionPointsPanel3.add( functionTextField3[ 20] );

        for(int i=3;i<=20;i++){
        functionTextField3[i].disable();
        }

        easyLabel4.setFont( new Font( "arial" , 1 , 11 ) );
        nominalLabel4.setFont( new Font( "arial" , 1 , 11 ) );
        difficultLabel4.setFont( new Font( "arial" , 1 , 11 ) );
        sysOsceLabelNoReuse.setFont( new Font( "arial" , 1 , 11 ) );
        sysOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );
        reuseSysOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );
        modifiedOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );
        deletedOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );
        adoptedOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );
        managedOsceLabel.setFont( new Font( "arial" , 1 , 11 ) );

        easyLabel4.setHorizontalAlignment( JLabel.CENTER );
        nominalLabel4.setHorizontalAlignment( JLabel.CENTER );
        difficultLabel4.setHorizontalAlignment( JLabel.CENTER );
        sysOsceLabelNoReuse.setHorizontalAlignment( JLabel.CENTER );
        sysOsceLabel.setHorizontalAlignment( JLabel.CENTER );
        reuseSysOsceLabel.setHorizontalAlignment( JLabel.CENTER );
        modifiedOsceLabel.setHorizontalAlignment( JLabel.CENTER );
        deletedOsceLabel.setHorizontalAlignment( JLabel.CENTER );
        adoptedOsceLabel.setHorizontalAlignment( JLabel.CENTER );
        managedOsceLabel.setHorizontalAlignment( JLabel.CENTER );

       easyLabel4.setBounds(270, 20, 50, 20);
        nominalLabel4.setBounds(330, 20, 50, 20);
        difficultLabel4.setBounds(390, 20, 50, 20);
        sysOsceLabelNoReuse.setBounds( 0 , 40 , 280 , 20 );
        sysOsceLabel.setBounds( 0 , 60 , 280 , 20 );
        reuseSysOsceLabel.setBounds( 0 , 80 , 280 , 20 );
        modifiedOsceLabel.setBounds( 0 , 100 , 280 , 20 );
        deletedOsceLabel.setBounds( 0 , 120 , 280 , 20 );
        adoptedOsceLabel.setBounds( 0 , 140 , 280 , 20 );
        managedOsceLabel.setBounds( 0 , 160 , 280 , 20 );


        JPanel functionPointsPanel4 = new JPanel( null );
        functionPointsPanel4.add( easyLabel4 );
        functionPointsPanel4.add( nominalLabel4 );
        functionPointsPanel4.add( difficultLabel4 );
        functionPointsPanel4.add( sysOsceLabelNoReuse );
        functionPointsPanel4.add( sysOsceLabel );
        functionPointsPanel4.add( reuseSysOsceLabel );
        functionPointsPanel4.add( modifiedOsceLabel );
        functionPointsPanel4.add( deletedOsceLabel );
        functionPointsPanel4.add( adoptedOsceLabel );
        functionPointsPanel4.add( managedOsceLabel );


        functionTextField4[ 0] = new JTextField();
        functionTextField4[ 1] = new JTextField();
        functionTextField4[ 2] = new JTextField();
        functionTextField4[ 3] = new JTextField();
        functionTextField4[ 4] = new JTextField();
        functionTextField4[ 5] = new JTextField();
        functionTextField4[ 6] = new JTextField();
        functionTextField4[ 7] = new JTextField();
        functionTextField4[ 8] = new JTextField();
        functionTextField4[ 9] = new JTextField();
        functionTextField4[ 10] = new JTextField();
        functionTextField4[ 11] = new JTextField();
        functionTextField4[ 12] = new JTextField();
        functionTextField4[ 13] = new JTextField();
        functionTextField4[ 14] = new JTextField();
        functionTextField4[ 15] = new JTextField();
        functionTextField4[ 16] = new JTextField();
        functionTextField4[ 17] = new JTextField();
        functionTextField4[ 18] = new JTextField();
        functionTextField4[ 19] = new JTextField();
        functionTextField4[ 20] = new JTextField();

        functionTextField4[ 0].setBounds( 285 , 40 , 50 , 20 );
        functionTextField4[ 1].setBounds( 335 , 40 , 50 , 20 );
        functionTextField4[ 2].setBounds( 385 , 40 , 50 , 20 );
        functionTextField4[ 3].setBounds( 285 , 60 , 50 , 20 );
        functionTextField4[ 4].setBounds( 335 , 60 , 50 , 20 );
        functionTextField4[ 5].setBounds( 385 , 60 , 50 , 20 );
        functionTextField4[ 6].setBounds( 285 , 80 , 50 , 20 );
        functionTextField4[ 7].setBounds( 335 , 80 , 50 , 20 );
        functionTextField4[ 8].setBounds( 385 , 80 , 50 , 20 );
        functionTextField4[ 9].setBounds( 285 , 100 , 50 , 20 );
        functionTextField4[ 10].setBounds( 335 , 100 , 50 , 20 );
        functionTextField4[ 11].setBounds( 385 , 100 , 50 , 20 );
        functionTextField4[ 12].setBounds( 285 , 120 , 50 , 20 );
        functionTextField4[ 13].setBounds( 335 , 120 , 50 , 20 );
        functionTextField4[ 14].setBounds( 385 , 120 , 50 , 20 );
        functionTextField4[ 15].setBounds( 285 , 140 , 50 , 20 );
        functionTextField4[ 16].setBounds( 335 , 140 , 50 , 20 );
        functionTextField4[ 17].setBounds( 385 , 140 , 50 , 20 );
        functionTextField4[ 18].setBounds( 285 , 160 , 50 , 20 );
        functionTextField4[ 19].setBounds( 335 , 160 , 50 , 20 );
        functionTextField4[ 20].setBounds( 385 , 160 , 50 , 20 );

        functionPointsPanel4.add( functionTextField4[ 0] );
        functionPointsPanel4.add( functionTextField4[ 1] );
        functionPointsPanel4.add( functionTextField4[ 2] );
        functionPointsPanel4.add( functionTextField4[ 3] );
        functionPointsPanel4.add( functionTextField4[ 4] );
        functionPointsPanel4.add( functionTextField4[ 5] );
        functionPointsPanel4.add( functionTextField4[ 6] );
        functionPointsPanel4.add( functionTextField4[ 7] );
        functionPointsPanel4.add( functionTextField4[ 8] );
        functionPointsPanel4.add( functionTextField4[ 9] );
        functionPointsPanel4.add( functionTextField4[ 10] );
        functionPointsPanel4.add( functionTextField4[ 11] );
        functionPointsPanel4.add( functionTextField4[ 12] );
        functionPointsPanel4.add( functionTextField4[ 13] );
        functionPointsPanel4.add( functionTextField4[ 14] );
        functionPointsPanel4.add( functionTextField4[ 15] );
        functionPointsPanel4.add( functionTextField4[ 16] );
        functionPointsPanel4.add( functionTextField4[ 17] );
        functionPointsPanel4.add( functionTextField4[ 18] );
        functionPointsPanel4.add( functionTextField4[ 19] );
        functionPointsPanel4.add( functionTextField4[ 20] );

        for(int i=3;i<=20;i++){
        functionTextField4[i].disable();
        }
        for(int i=0;i<20;i++)
        {
            functionTextField1[i].setText("");
            functionTextField2[i].setText("");
            functionTextField3[i].setText("");
            functionTextField4[i].setText("");
        }
        
        



        // Tabs
        tabs.addTab( "# of System Requirements" , functionPointsPanel1 );
        tabs.addTab( "# of System Interfaces" , functionPointsPanel2 );
        tabs.addTab( "# of Algorithms" , functionPointsPanel3 );
        tabs.addTab( "# of Operational Scenarios" , functionPointsPanel4 );
        tabs.addChangeListener( this ) ;

        // GUI
        JPanel northPanel = new JPanel( null );
        northPanel.setPreferredSize( new Dimension( 100 , 120 ) );
        JPanel southPanel = new JPanel();
        JPanel checkBoxPanel = new JPanel();
        checkBoxPanel.add(checkBox);

        southPanel.add( applyButton );
        southPanel.add( closeButton );

        this.setLayout( new BorderLayout() );
        this.add(checkBoxPanel, BorderLayout.PAGE_START);
        this.add( northPanel , BorderLayout.NORTH );
        this.add( tabs );
        this.add( southPanel , BorderLayout.SOUTH );

        // Loading ...
    //    loadParameters();

        this.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
        this.setLocation( this.getOwner().getX() + 100 , this.getOwner().getY() + 100 );
        this.setResizable( true );
        this.setSize(640 , 480 );
        this.setVisible( true );
    }

    /**
     *
     */
    public void loadParameters()
    {

       
      /*  tabs.setSelectedIndex( subSystem.getSizingType() ) ;

        applyButton.setEnabled( false );
        closeButton.setEnabled( false );

        functionTextField[ 0 ].setText( subSystem.getExternalInputs()[ 0 ] + "" );
        functionTextField[ 1 ].setText( subSystem.getExternalInputs()[ 1 ] + "" );
        functionTextField[ 2 ].setText( subSystem.getExternalInputs()[ 2 ] + "" );
        functionTextField[ 3 ].setText( subSystem.getExternalOutputs()[ 0 ] + "" );
        functionTextField[ 4 ].setText( subSystem.getExternalOutputs()[ 1 ] + "" );
        functionTextField[ 5 ].setText( subSystem.getExternalOutputs()[ 2 ] + "" );
        functionTextField[ 6 ].setText( subSystem.getInternalLogicalFiles()[ 0 ] + "" );
        functionTextField[ 7 ].setText( subSystem.getInternalLogicalFiles()[ 1 ] + "" );
        functionTextField[ 8 ].setText( subSystem.getInternalLogicalFiles()[ 2 ] + "" );
        functionTextField[ 9 ].setText( subSystem.getExternalInterfaceFiles()[ 0 ] + "" );
        functionTextField[ 10 ].setText( subSystem.getExternalInterfaceFiles()[ 1 ] + "" );
        functionTextField[ 11 ].setText( subSystem.getExternalInterfaceFiles()[ 2 ] + "" ); */
        
     
        // Set Back To Default ...
        applyButton.setEnabled( true );
        closeButton.setEnabled( true );

        GlobalMethods.updateStatusBar( "Parameters Loaded." );
    }

    public void actionPerformed( ActionEvent e )
    {
        if ( e.getSource() == applyButton )
        {
            int flag;
            flag =0;
            float size_param_nonreuse[] = new float[ 12 ] ;
            float size_param_reuse[] = new float [72];
            int ind1 =0;
            int ind2=3;
            int ind3=6;
            int ind4=9;
         //Arnab
            for(int i=0;i<3;i++)
            {
               if( (functionTextField1[i].getText()).length() != 0 || (functionTextField2[i].getText()).length() != 0 || (functionTextField3[i].getText()).length() !=0 || (functionTextField4[i].getText()).length() !=0 )
                   flag =1;
                if ((functionTextField1[i].getText()).length() != 0)
                    size_param_nonreuse[ind1++]=Float.parseFloat(functionTextField1[i].getText());
                else
                    size_param_nonreuse[ind1++]=0;
                if ((functionTextField2[i].getText()).length() == 0)
                    size_param_nonreuse[ind2++]=0;
                else
                    size_param_nonreuse[ind2++]=Float.parseFloat(functionTextField2[i].getText());
       
                if ((functionTextField3[i].getText()).length() == 0)
                    size_param_nonreuse[ind3++]=0;
                else
                size_param_nonreuse[ind3++]=Float.parseFloat(functionTextField3[i].getText());
             
               
               if ((functionTextField4[i].getText()).length() == 0)
                    size_param_nonreuse[ind4++]=0;
                else
                size_param_nonreuse[ind4++]=Float.parseFloat(functionTextField4[i].getText());
            }
            if (flag == 1)
            {
                subSystem.set_size_param_nonreuse(size_param_nonreuse);
                COINCOMOSubSystemManager.updateCosysmoSize_nonreuse(subSystem);
            }
            else
            {//call the resuable part
               ind1 =0;
               ind2=18;
               ind3=36;
               ind4=54;
                for(int i=3;i<20;i++)
            {
               if( (functionTextField1[i].getText()).length() != 0 || (functionTextField2[i].getText()).length() != 0 || (functionTextField3[i].getText()).length() !=0 || (functionTextField4[i].getText()).length() !=0 )
                   flag =1;
                if ((functionTextField1[i].getText()).length() != 0)
                    size_param_reuse[ind1++]=Float.parseFloat(functionTextField1[i].getText());
                else
                    size_param_reuse[ind1++]=0;
                if ((functionTextField2[i].getText()).length() == 0)
                    size_param_reuse[ind2++]=0;
                else
                    size_param_reuse[ind2++]=Float.parseFloat(functionTextField2[i].getText());
       
                if ((functionTextField3[i].getText()).length() == 0)
                    size_param_reuse[ind3++]=0;
                else
                size_param_reuse[ind3++]=Float.parseFloat(functionTextField3[i].getText());
             
               
               if ((functionTextField4[i].getText()).length() == 0)
                    size_param_reuse[ind4++]=0;
                else
                size_param_reuse[ind4++]=Float.parseFloat(functionTextField4[i].getText());
            }
               subSystem.set_size_param_reuse(size_param_reuse);
               COINCOMOSubSystemManager.updateCosysmoSize_reuse(subSystem);
            
            }
            
            //COINCOMOSubSystemManager.updateCosysmoSize_nonreuse(subSystem);
            
            // Function Points
       /*     for( int i = 0 ; i < functionTextField.length ; i ++ )
            {
                if( !GlobalMethods.isNonNegativeLong( functionTextField[ i ].getText() ) )
                {
                    GlobalMethods.updateStatusBar( "All Function Points Must be Non-Negative Integers" , Color.RED );

                    return;
                }
            }

            if( Long.parseLong( functionTextField[ 0 ].getText() ) > Long.parseLong( functionTextField[ 1 ].getText() )
                    || Long.parseLong( functionTextField[ 1 ].getText() ) > Long.parseLong( functionTextField[ 2 ].getText() ) )
            {
                GlobalMethods.updateStatusBar( "Input Function Point Average Must be between its Boundaries." , Color.RED );

                return;
            }

            if( Long.parseLong( functionTextField[ 3 ].getText() ) > Long.parseLong( functionTextField[ 4 ].getText() )
                    || Long.parseLong( functionTextField[ 4 ].getText() ) > Long.parseLong( functionTextField[ 5 ].getText() ) )
            {
                GlobalMethods.updateStatusBar( "Output Function Point Average Must be between its Boundaries." , Color.RED );

                return;
            }

            if( Long.parseLong( functionTextField[ 6 ].getText() ) > Long.parseLong( functionTextField[ 7 ].getText() )
                    || Long.parseLong( functionTextField[ 7 ].getText() ) > Long.parseLong( functionTextField[ 8 ].getText() ) )
            {
                GlobalMethods.updateStatusBar( "File Function Point Average Must be between its Boundaries." , Color.RED );

                return;
            }

            if( Long.parseLong( functionTextField[ 9 ].getText() ) > Long.parseLong( functionTextField[ 10 ].getText() )
                    || Long.parseLong( functionTextField[ 10 ].getText() ) > Long.parseLong( functionTextField[ 11 ].getText() ) )
            {
                GlobalMethods.updateStatusBar( "Interface Function Point Average Must be between its Boundaries." , Color.RED );

                return;
            }

            if( Long.parseLong( functionTextField[ 12 ].getText() ) > Long.parseLong( functionTextField[ 13 ].getText() )
                    || Long.parseLong( functionTextField[ 13 ].getText() ) > Long.parseLong( functionTextField[ 14 ].getText() ) )
            {
                GlobalMethods.updateStatusBar( "Query Function Point Average Must be between its Boundaries." , Color.RED );

                return;
            }

          

            applyButton.setEnabled( false );
            closeButton.setEnabled( false );

            GlobalMethods.updateStatusBar( "Saving ..." );

            ComponentOverviewPanel.estimationTextPane.setText( "Loading ..." );

            SwingUtilities.invokeLater( new Runnable()
            {
                public void run()
                {
                 
                    // Function Points
                    subSystem.setExternalInputs( new long[]{ Long.parseLong( functionTextField[0].getText() ) , Long.parseLong( functionTextField[1].getText() ) , Long.parseLong( functionTextField[2].getText() ) } ) ;
                    subSystem.setExternalOutputs( new long[]{ Long.parseLong( functionTextField[3].getText() ) , Long.parseLong( functionTextField[4].getText() ) , Long.parseLong( functionTextField[5].getText() )  } ) ;
                    subSystem.setInternalLogicalFiles( new long[]{ Long.parseLong( functionTextField[6].getText() ) , Long.parseLong( functionTextField[7].getText() ) , Long.parseLong( functionTextField[8].getText() )  } ) ;
                    subSystem.setExternalInterfaceFiles( new long[]{ Long.parseLong( functionTextField[9].getText() ) , Long.parseLong( functionTextField[10].getText() ) , Long.parseLong( functionTextField[11].getText() )  } ) ;
                    subSystem.setExternalInquiries( new long[]{ Long.parseLong( functionTextField[12].getText() ) , Long.parseLong( functionTextField[13].getText() ) , Long.parseLong( functionTextField[14].getText() ) } ) ;

                   

                    // Update Summary Report
                    ComponentOverviewPanel.updateEstimationTextPane( false );

                    // Set Back To Default ...
                    applyButton.setEnabled( true );
                    closeButton.setEnabled( true );

                    GlobalMethods.updateStatusBar( "Sub Component Saved." );
                }

            } );
     */   }
       if ( e.getSource() == closeButton )
        {
            // Free Resources ... Close Window
            this.dispose();
        }

       if ( e.getSource() == checkBox)
        {
           String[] choices = {"Yes", "No"};
           int response=0;
           for(int i=0;i<=20;i++){
           if((functionTextField1[i].getText()).length()!=0){
           popupflag='y';
           }
           }
           if(checkBox.isSelected()==true){

               if(popupflag=='y'){
               response=JOptionPane.showOptionDialog(rootPane, "Do you really want to change the option? If yes, then all pre entered data will get erased","Option Box",JOptionPane.YES_NO_OPTION,JOptionPane.PLAIN_MESSAGE,null,choices,"No");
               }

               if(response==1){
               
               }
               else{
               for(int i=0;i<=20;i++){
               functionTextField1[i].setText("");
               functionTextField2[i].setText("");
               functionTextField3[i].setText("");
               functionTextField4[i].setText("");
               }
               for(int i=0;i<=2;i++){
               functionTextField1[i].disable();
               functionTextField1[i].setBackground(Color.RED);
               functionTextField2[i].disable();
               functionTextField2[i].setBackground(Color.RED);
               functionTextField3[i].disable();
               functionTextField3[i].setBackground(Color.RED);
               functionTextField4[i].disable();
               functionTextField4[i].setBackground(Color.RED);
               }
               for(int i=3;i<=20;i++){
               functionTextField1[i].enable();
               functionTextField1[i].setBackground(Color.WHITE);
               functionTextField2[i].enable();
               functionTextField2[i].setBackground(Color.WHITE);
               functionTextField3[i].enable();
               functionTextField3[i].setBackground(Color.WHITE);
               functionTextField4[i].enable();
               functionTextField4[i].setBackground(Color.WHITE);

               }

               }

              }
            else {


               if(popupflag=='y'){
               response=JOptionPane.showOptionDialog(rootPane, "Do you really want to change the option?","Option Box",JOptionPane.YES_NO_OPTION,JOptionPane.PLAIN_MESSAGE,null,choices,"No");
               }

               if(response==1){

               }
               else{
               for(int i=0;i<=20;i++){
               functionTextField1[i].setText("");
               functionTextField2[i].setText("");
               functionTextField3[i].setText("");
               functionTextField4[i].setText("");
               }
               for(int i=3;i<=20;i++){
               functionTextField1[i].disable();
               functionTextField1[i].setBackground(Color.RED);
               functionTextField2[i].disable();
               functionTextField2[i].setBackground(Color.RED);
               functionTextField3[i].disable();
               functionTextField3[i].setBackground(Color.RED);
               functionTextField4[i].disable();
               functionTextField4[i].setBackground(Color.RED);

               }
               for(int i=0;i<=2;i++){
               functionTextField1[i].enable();
               functionTextField1[i].setBackground(Color.WHITE);
               functionTextField2[i].enable();
               functionTextField2[i].setBackground(Color.WHITE);
               functionTextField3[i].enable();
               functionTextField3[i].setBackground(Color.WHITE);
               functionTextField4[i].enable();
               functionTextField4[i].setBackground(Color.WHITE);


               }

               }
            }

           }
         
        
    }

    public void stateChanged( ChangeEvent e )
    {
        JTabbedPane pane = (JTabbedPane)e.getSource();

        subSystem.setSizingType( pane.getSelectedIndex() );
    }
}
